<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入0-100之间的整数" id="i">
<input type="button" value="猜一猜" onclick="f()">
<div>结果：<span></span></div>
<script>
    let num1 = parseInt(Math.random() * 101)
    let n = 0;
    function f(x) {
        n++
        let num2 = parseInt(document.querySelector("#i").value)
        let s = document.querySelector("span")
        if (isNaN(num2)){
            s.innerText="输出错误！"
            return;
        }
        if (num2 < num1) {
            s.innerText = "猜小了，请继续"
        } else if (num2 > num1) {
            s.innerText = "猜大了，请继续"
        }else {
            s.innerText = "恭喜您第" + n + "次猜对了！"
        }


    }


</script>
</body>
</html>